package method;

import java.util.Scanner;

public class Calculator {

    public double add(double a,double b) {
        return a+b;
    }

    public double subtract(double a,double b) {
        return a-b;
    }

    public double multiply(double a,double b) {
        return a*b;
    }

    public double divide(double a,double b) {
        return a/b;
    }

    public static void main(String[] args) {
        String str = null;
        double a = 0;
        double b = 0;
        Calculator count = new Calculator();
        Scanner scanner = new Scanner(System.in);
        System.out.println("Input +,-,*,/ to next");
        while(scanner.hasNext()){
            str = scanner.next();
            switch (str) {
                case "+":
                    System.out.println("Input two numbers");
                    a = scanner.nextDouble();
                    b = scanner.nextDouble();
                    System.out.println("a+b="+count.add(a,b));
                    break;
                case "-":
                    System.out.println("Input two numbers");
                    a = scanner.nextDouble();
                    b = scanner.nextDouble();
                    System.out.println("a-b="+count.subtract(a,b));
                    break;
                case "*":
                    System.out.println("Input two numbers");
                    a = scanner.nextDouble();
                    b = scanner.nextDouble();
                    System.out.println("a*b="+count.multiply(a,b));
                    break;
                case "/":
                    System.out.println("Input two numbers");
                    a = scanner.nextDouble();
                    b = scanner.nextDouble();
                    System.out.println("a/b="+count.divide(a,b));
                    break;
                default:
                    System.out.println("Error!");
            }
            System.out.println("Input +,-,*,/ to next");
        }

    }
}
